导<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main2"/>
    <title>商机列表</title>
</head>

<body>
<div class="main-body">
    <div class="page-wrapper">
        <div class="page-header">
            <div class="page-header-title">
                <h4>商机列表</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item"><a href="#!">商机列表</a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="page-body">
            <div class="card">
                <div class="card-header">
                    <h5>商机列表</h5>
                    <div class="card-header-right">
                        <g:link action="create"><i class="ion-plus"></i> 新增</g:link>
                    </div>
                </div>

                <div class="card-block">

                    <div class="dt-responsive table-responsive">
                        <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">

                            <g:form method="POST" action="searchOpportunity">
                                <div class="row m-0">
                                    <div class="col-md-10 p-l-0">
                                        <div id="dom-jqry_filter" class="text-left">
                                            <label class="block">
                                            <div class="form-group row">
                                              <div class="col-md-3">
                                            <input type="text" class="form-control" placeholder="商机编号" name="serialNumber" id="serialNumber" value="${params?.serialNumber}">
                                            </div>
                                            <div class="col-md-3">
                                            <input type="text" class="form-control" placeholder="客户名称" name="accountName" id="accountName" value="${params?.accountName}">
                                          </div>
                                          <div class="col-md-3">
                                            <!-- <input type="text" class="form-control" placeholder="产品名称" name="productName" id="productName" value="${params?.productName}"> -->
                                            <g:select class="form-control" name="productName" id="productName" optionValue="name"
                                          optionKey="name"
                                          from="${com.next.Product.list()}" value="${params?.productName}"
                                          noSelection="${['': '产品']}"/>
                                        </div>
                                        <div class="col-md-3">
                                            <!-- <input type="text" class="form-control" placeholder="部门" name="department" id="department" value="${params?.department}"> -->
                                            <g:select class="form-control" name="department" id="department" optionValue="name"
                                            optionKey="name"
                                            from="${com.next.Department.list()}" value="${params?.department}"
                                            noSelection="${['': '部门']}"/>
                                          </div>
                                            </div>
                                            <div class="form-group row">
                                              <div class="col-md-3">
                                            <!-- <input type="text" class="form-control" placeholder="销售人员" name="owner" id="owner" value="${params?.owner}"> -->
                                            <g:select class="form-control" name="owner" id="owner" optionValue="fullName"
                                            optionKey="fullName"
                                            from="${com.next.User.list()}" value="${params?.owner}"
                                            noSelection="${['': '销售人员']}"/>
                                            </div>
                                            <div class="col-md-3">
                                            <!-- <input type="text" class="form-control" placeholder="商机阶段" name="opportunityStage" id="opportunityStage" value="${params?.opportunityStage}"> -->
                                          <g:select class="form-control" name="opportunityStage" id="opportunityStage" optionValue="name"
                                          optionKey="name"
                                          from="${com.next.OpportunityStage.list()}" value="${params?.opportunityStage}"
                                          noSelection="${['': '阶段']}"/>
                                        </div>
                                        <div class="col-md-3">
                                            <!-- <input type="text" class="form-control" placeholder="商机类型" name="opportunityType" id="opportunityType" value="${params?.opportunityType}"> -->
                                           <g:select class="form-control" name="opportunityType" id="opportunityType" optionValue="name"
                                          optionKey="name"
                                          from="${com.next.OpportunityType.list()}" value="${params?.opportunityType}"
                                          noSelection="${['': '类型']}"/>
                                        </div>
                                        <div class="col-md-3">
                                            <!-- <input type="text" class="form-control" placeholder="产品线" name="productLine" id="productLine" value="${params?.productLine}"> -->
                                            <g:select class="form-control" name="productLine" id="productLine" optionValue="name"
                                            optionKey="name"
                                            from="${com.next.ProductLine.list()}" value="${params?.productLine}"
                                            noSelection="${['': '产品线']}"/>
                                          </div>
                                            </div>
                                            <div class="form-group row">
                                              <div class="col-md-3">
                                            <input type="text" class="form-control" placeholder="最小金额" name="minAmount" id="minAmount" value="${params?.minAmount}">
                                            </div>
                                            <div class="col-md-3">
                                            <input type="text" class="form-control" placeholder="最大金额" name="maxAmount" id="maxAmount" value="${params?.maxAmount}">
                                          </div>
                                          <div class="col-md-3">
                                            <input type="text" valctrl="startTime" value="${params?.startTime}" placeholder="开始时间" class="form-control form_date">
                                            <input type="hidden" id="startTime" name="startTime" value="date.struct">
                                            <input type="hidden" id="startTime_day" name="startTime_day" value="">
                                            <input type="hidden" id="startTime_month" name="startTime_month" value="">
                                            <input type="hidden" id="startTime_year" name="startTime_year" value="">
                                          </div>
                                          <div class="col-md-3">
                                            <input type="text" valctrl="endTime" value="${params?.endTime}" placeholder="结束时间" class="form-control form_date">
                                            <input type="hidden" id="endTime" name="endTime" value="date.struct">
                                            <input type="hidden" id="endTime_day" name="endTime_day" value="">
                                            <input type="hidden" id="endTime_month" name="endTime_month" value="">
                                            <input type="hidden" id="endTime_year" name="endTime_year" value="">
                                          </div>
                                            </div>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="col-md-2 p-r-0 dt-buttons text-right">
                                            <button class="btn btn-inverse btn-sm btn-squeare" type="submit"><i class="fa fa-search"></i></button>
                                            <button class="btn btn-inverse btn-sm btn-squeare" type="button" id="resetBtn"><i class="fa fa-refresh"></i></button>
                                    </div>
                                </div>
                            </g:form>
                          %{--
                          <g:form method="POST" action="exportOpportunity">
                                <div class="row m-0">
                                    <input type="hidden" class="form-control" placeholder="商机号" name="serialNumber" id="exportSerialNumber" value="${params?.serialNumber}">
                                    <input type="hidden" class="form-control" placeholder="文件类型" name="f" value="excel">
                                    <input type="hidden" class="form-control" placeholder="后缀" name="extension" value="xls">
                                    <div class="col-md-12 p-r-0 dt-buttons text-right">
                                    <button class="btn btn-success btn-mini" type="submit"><i class="icofont icofont-search"></i>导出</button>
                                </div>
                                </div>
                            </g:form>
                            --}%
                            <table class="table table-striped  table-bordered table-hover">
                                <thead>
                                <tr>
                                    <g:sortableColumn property="id" title="编号"></g:sortableColumn>
                                    <g:sortableColumn property="serialNumber" title="商机号"></g:sortableColumn>
                                    <g:sortableColumn property="account" title="客户名称"></g:sortableColumn>
                                    <g:sortableColumn property="amount" title="金额"></g:sortableColumn>
                                    <g:sortableColumn property="probability" title="几率"></g:sortableColumn>
                                    <g:sortableColumn property="status" title="状态"></g:sortableColumn>
                                    <g:sortableColumn property="stage" title="阶段"></g:sortableColumn>
                                    <g:sortableColumn property="product" title="产品"></g:sortableColumn>
                                    <g:sortableColumn property="startTime" title="商机发现时间"></g:sortableColumn>
                                    <g:sortableColumn property="endTime" title="客户预计采购时间"></g:sortableColumn>
                                </tr>
                                </thead>
                                <tbody>
                                <g:each in="${opportunityList}">
                                    <tr>
                                        <td>
                                            <g:link action="show" id="${it?.id}">${it?.id}</g:link>
                                        </td>
                                        <td>
                                            <g:link action="show" id="${it?.id}">${it?.serialNumber}</g:link>
                                        </td>
                                        <td>${it?.account}</td>
                                        <td>${Math.round(new BigDecimal(it?.amount))}</td>
                                        <td>${it?.probability}</td>
                                        <td>${it?.status?.name}</td>
                                        <td>${it?.stage?.name}</td>
                                        <td>${it?.product?.name}</td>
                                        <td><g:formatDate date="${it?.startTime}"
                                                          format="yyyy-MM-dd"></g:formatDate></td>
                                        <td><g:formatDate date="${it?.endTime}"
                                                          format="yyyy-MM-dd"></g:formatDate></td>
                                    </tr>
                                </g:each>
                                </tbody>
                            </table>
                            <div class="row m-0">
                              <div class="col-xs-12 col-sm-12 col-md-5">
                                <div class="dataTables_info" id="dom-jqry_info" role="status" aria-live="polite">每页10条，共${opportunityCount}条</div>
                              </div>
                              <div class="col-xs-12 col-sm-12 col-md-7">
                            <div class="dataTables_paginate" id="dom-jqry_paginate">
                                 <div class="pagination">
                                    <g:paginate total="${opportunityCount ?: 0}" params="${params}"/>

                                 </div>
                            </div>
                            </div>
                            </div>

                        </div>

                    </div>

                </div>
            </div>
            <!-- Hover table card end -->
        </div>

        <!-- Page-body end -->
    </div>
</div>

<g:javascript>
    $(function () {
        $("#resetBtn").click(function () {
            $("#serialNumber").val("");
            $("#accountName").val("");
            $("#productName").val("");
            $("#select2-productName-container").text("产品");
            $("#department").val("");
            $("#select2-department-container").text("部门");
            $("#owner").val("");
            $("#select2-owner-container").text("销售人员");
            $("#opportunityStage").val("");
            $("#select2-opportunityStage-container").text("阶段");
            $("#opportunityType").val("");
            $("#select2-opportunityType-container").text("类型");
            $("#productLine").val("");
            $("#select2-productLine-container").text("产品线");
            $("#minAmount").val("");
            $("#maxAmount").val("");
            $(".form_date").val("");
            $(".form_date").change();
        })
    });

</g:javascript>
</body>
</html>
